using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

public partial class themes_Athemia_site : System.Web.UI.MasterPage
{
  protected void Page_Load(object sender, EventArgs e)
  {
		if (Page.User.Identity.IsAuthenticated)
		{
			aLogin.InnerText = Resources.labels.logoff;
			aLogin.HRef = BlogEngine.Core.Utils.RelativeWebRoot + "login.aspx?logoff";
		}
		else
		{
			aLogin.HRef = BlogEngine.Core.Utils.RelativeWebRoot + "login.aspx";
			aLogin.InnerText = Resources.labels.login;
		}

        if (Request.QueryString.Count == 0 && Request.RawUrl.Replace("?","").EndsWith("/default.aspx",StringComparison.OrdinalIgnoreCase))
        {
            string query = Request.QueryString["theme"];
            string theme = !string.IsNullOrEmpty(query) ? query : BlogSettings.Instance.Theme;
            string path = string.Concat(Utils.RelativeWebRoot, "themes/", theme, "/PostViewFrontPage.ascx");
            //Control.MapPath() 

            PostViewBase postView = (BlogEngine.Core.Web.Controls.PostViewBase)LoadControl(path);
            postView.ShowExcerpt = true;// BlogSettings.Instance.ShowDescriptionInPostList;
            //just set a temp post to show - for not getting error
            Post tmp = BlogEngine.Core.Post.Posts[0];
            postView.Post = tmp;
            postView.ID = "sdfsdfsf";// tmp.Id.ToString().Replace("-", string.Empty);
            postView.Location = ServingLocation.PostList;

            fronttop.Controls.Add(postView);
        }
  }

}
